package com.e3.basdoc.goods.service;

import java.util.List;

import com.e3.basdoc.goods.model.GoodsModel;
import com.e3.core.base.ServiceLocator;
import com.e3.core.cache.CacheLoader;

public class GoodsCacheLoader implements CacheLoader {
	
	private GoodsQueryService goodsQueryService;
	
	private GoodsQueryService getGoodsQueryService(){
		if(goodsQueryService == null){
			goodsQueryService = ServiceLocator.getQueryService(GoodsQueryService.class);
		}
		return goodsQueryService;
	}

	public void loadeData() throws Exception {
		List<GoodsModel> models = getGoodsQueryService().getAllGoodss();
		if(models==null||models.isEmpty()){
			return;
		}
		for (GoodsModel model : models) {
			GoodsCacheManager.INSTANCE.put(model);
		}

	}

}
